<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>选择起始节点</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            width: 500px;
            height: 400px;
            font-family: "Microsoft YaHei", sans-serif;
            background: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .container {
            width: 400px;
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            padding: 30px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #333;
        }
        select, input[type="text"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 14px;
            box-sizing: border-box;
        }
        select:focus, input[type="text"]:focus {
            border-color: #409eff;
            outline: none;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="form-group">
            <label for="taskType">任务类型</label>
            <select id="taskType" name="taskType">
                <option value="AgTask">奥格任务</option>
                <option value="Grid">Grid</option>
            </select>
        </div>
        <div class="form-group">
            <label for="startName">起始名称</label>
            <input type="text" id="startName" name="startName" placeholder="请输入起始名称">
        </div>
        <div class="form-group" style="text-align: right;">
            <button id="closeBtn" style="margin-right: 10px; padding: 8px 16px; border: 1px solid #ccc; background: #fff; border-radius: 4px; cursor: pointer;">关闭</button>
            <button id="confirmBtn" style="padding: 8px 16px; border: 1px solid #409eff; background: #409eff; color: #fff; border-radius: 4px; cursor: pointer;">确定</button>
        </div>
    </div>
</body>
<script>
    // 关闭按钮点击事件
    document.getElementById('closeBtn').addEventListener('click', function () {
        window.parent.postMessage("close");
    });
    // 确定按钮点击事件
    document.getElementById('confirmBtn').addEventListener('click', function () {
        const taskType = document.getElementById('taskType').value;
        const startName = document.getElementById('startName').value;
        if (!taskType || !startName) {
            alert('请选择任务类型并输入起始名称');
            return;
        }
        // 发送数据到父窗口
        window.parent.postMessage({ "entityType":taskType, "startEntityName":startName }, '*');
        // 关闭弹窗
        window.parent.postMessage("close");
    });
</script>
</html>
